$(function () {
    var url='../userExchange/list'
    $("#jqGrid").Grid({
        url: url,
        datatype: "json",
        height: '400',
        // mtype:'POST',
        colModel: [
            {label: 'id', name: 'id', index: 'id'},
            {label: '用户名', name: 'userEntity.nickname', index: 'nickName'},
            // {label: '分享人姓名', name: 'parentName', index: 'parentName',formatter:function(cellvalue, options, rowObj){
            //         return "<span id='"+rowObj.parentId+"' class='mark_data'>"+cellvalue+"</span>";
            // }},
            {label: '礼包类型名称', name: 'giftTypeEntity.giftName', index: 'giftTypeEntity.giftName'},
            {label: '卡号', name: 'exchangeCodeEntity.cardNumber', index: 'exchangeCodeEntity.cardNumber'},
            {label: '兑换码', name: 'exchangeCodeEntity.exchangeCode', index: 'exchangeCodeEntity.exchangeCode'},
            {label: '兑换时间', name: 'exchangeTime', index: 'exchangeTime',formatter: function (value){
                    var time = new Date(value);
                    var y = time.getFullYear();
                    var m = time.getMonth()+1;
                    var d = time.getDate();
                    var h = time.getHours();
                    var mm = time.getMinutes();
                    var s = time.getSeconds();
                    var add0=function (m) {
                        return m<10?'0'+m:m
                    }
                    return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
                }},

            {label: '订单号', name: 'orderSn', index: 'orderSn'},
            {label: '订单状态', name: 'orderEntity.orderStatus', index: 'orderEntity.orderStatus',formatter: function (value){
                    if (value == '0') {
                        return '待付款';
                    } else if (value == '101') {
                        return '订单已取消';
                    } else if (value == '102') {
                        return '订单已删除';
                    } else if (value == '201') {
                        return '订单待发货';
                    } else if (value == '300') {
                        return '订单已发货';
                    } else if (value == '301') {
                        return '用户确认收货';
                    } else if (value=='302'){
                        return '自提';
                    }else if (value == '401') {
                        return '退款';
                    } else if (value == '402') {
                        return '完成';
                    }
                }},

            // {label: '分享时间', name: 'createTime', index: 'createTime'},
        ]
    });

});

let vm = new Vue({
    el: '#rrapp',
    data: {
        q: {
            param:''

        },
        listDataShow:true
    },
    methods: {
        listExport() {
            exportFile('#rrapp', '../userExchange/export',{parentId:''});
        },
        query(){
            vm.reload()
            // this.listDataShow=false
        },
        reload(){
            var page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'giftName': vm.q.param},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        }
    },
    created: function () {

    }
});